package cn.tedu._03vehicle.pojo.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.*;
import lombok.Data;

@Data
public class UserRegParam {
    //@NotNull(message = "用户名不能为null")
    //@NotEmpty(message = "用户名不能为空字符串和null")
    //@NotBlank(message = "用户名不能为空字符串和null和空白字符串")
    //@Size(min = 6, max = 10, message = "用户名长度必须在6到10之间")
    @Pattern(regexp = "^(?:[\\u4e00-\\u9fa5]{1,7}|[a-zA-Z]{1,14})$", message = "用户名最长为7个汉字或14个英文")
    @Schema(description = "用户名", required = true)
    private String username;

    /*
        AI提示词:
        在Spring Validation框架中，使用@Pattern()注解校验数据合法性中，密码合法性要求如下：
        1. 长度为8-14个字符
        2. 字母/数字以及标点符号至少包含2种
        3. 不允许有空格、中文
        请写出正则表达式
     */
    @Pattern(regexp = "^(?!.*[\\s\\u4e00-\\u9fa5])((?=.*[a-zA-Z])(?=.*[\\d])|(?=.*[a-zA-Z])(?=.*[\\p{Punct}])|(?=.*[\\d])(?=.*[\\p{Punct}]))[\\w\\p{Punct}]{8,14}$", message = "密码不合法")
    @Schema(description = "密码", required = true)
    private String password;

    //@Email(message = "邮箱格式不正确")
    @Pattern(regexp = "^[\\w.-]+@[\\w.-]+\\.[a-zA-Z]{2,}$", message = "请输入合法的邮箱地址")
    @Schema(description = "邮箱", required = true)
    private String email;

    @Pattern(regexp = "^(?:(?:\\+|00)86)?1[3-9]\\d{9}$", message = "请输入合法的手机号")
    @Schema(description = "手机号码", required = true)
    private String phone;
}
